/**
 * Created by arons on 16/6/29.
 */

function testForOf(){
    "use strict";
    var a = [1, 2, 3];
    console.log(a);
    for (var x of a) {
        console.log(x);
    }
}

function testForIn(){
    var a = ['A', 'B', 'C'];
    a.name = 'Hello';
    for (var x in a) {
        console.log(x); // '0', '1', '2', 'name'
    }

    for (var x of a) {
        console.log(x); 'A', 'B', 'C'
    }
}

function testForEach(){
    var a = ['A', 'B', 'C'];
    a.name = 'Hello';
    //a.forEach(element, index, array){
    //    console.log(element, index, array);
    //}

    a.forEach(function (element, index, array) {
        console.log(element, index, array);
    });

    var se = new Set('A', 'B', 'C');
    se.forEach(function (element, index, array) {
        console.log(element, index, array);
    });

    var map = new Map([[1, 'x'], [2, 'y'], [3, 'z']]);
    map.forEach(function (element, index, array) {
        console.log(element, index, array);
    });
}


testForEach();